package com.jsz.peini.server.thread;

import org.apache.log4j.Logger;

import com.jsz.peini.bean.activity.ActivityInfo;
import com.jsz.peini.bean.activity.ActivityUser;
import com.jsz.peini.common.util.PeiniUtils;
import com.jsz.peini.common.util.SpringContextUtil;
import com.jsz.peini.mapper.activity.ActivityInfoMapper;
import com.jsz.peini.mapper.activity.ActivityUserMapper;


public class ActivityUserThread extends Thread{
	
	Logger logger = Logger.getLogger(ActivityUserThread.class);
	
	private ActivityUserMapper activityUserMapper;
	
	private ActivityInfoMapper activityInfoMapper;
	
	public void init(){
		this.start();
	}
	
	@Override
	public void run() {
		super.run();
		
		activityUserMapper = (ActivityUserMapper)SpringContextUtil.getBean(ActivityUserMapper.class);
		
		activityInfoMapper = (ActivityInfoMapper)SpringContextUtil.getBean(ActivityInfoMapper.class);
		
		while(true)
		{
			try {
				/*ActivityUser acUser = PeiniUtils.activityUserList.take();
				
				activityUserMapper.insertSelective(acUser);
				ActivityInfo info = acUser.getActivityInfo();
				info.setRegUserCnt(info.getRegUserCnt() == null ? 1 : info.getRegUserCnt()+1);
				activityInfoMapper.updateByPrimaryKey(info);*/
				
				Thread.sleep(1);
			} catch (Exception e1) {
				e1.printStackTrace();
				logger.info("fail", e1);
			}
		}
		
	}
	
}